<?php

use yii\widgets\ActiveForm;
use kartik\select2\Select2;



$this->title = '创建/修改';
$this->params['breadcrumbs'][] = ['label' => '排班管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\addons\Attend\backend\assets\AppAsset::register($this);
?>

    <div class="row">
        <div class="col-lg-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">修改排班</h3>
                </div>
                <div class="box-body">

                    <?php $form = ActiveForm::begin([
                        'fieldConfig' => [
                            'template' => "<div class='col-sm-1 text-right'>{label}</div><div class='col-sm-11'>{input}\n{hint}\n{error}</div>",
                        ],
                    ]); ?>
                    <div class="col-sm-12">

                        <div id="simpliest-usage" class="box " ></div>

                    </div>
                    <?= $form->field($model, 'check_date')->hiddenInput()->label(false)?>

                    <div class="form-group">
                        <div class="col-sm-12 text-center">
                            <button id="btnGetDates" class="btn btn-primary" type="submit">保存排班时期</button>
                        </div>
                    </div>

                    <?php ActiveForm::end(); ?>
                </div>
            </div>
        </div>
    </div>

<?php
$js = <<<JS

     var today = new Date();
     var y = today.getFullYear();
    
     var date = new Date();
     // var dates = ['2020-05-30','2020-05-31'];
     var dates = '{$model->check_date}';
     dates = dates.split(",");   
            $.datepicker.regional['zh-CN'] = {
                closeText: '关闭',
                prevText: '&#x3c;上月',
                nextText: '下月&#x3e;',
                currentText: '今天',
                monthNames: ['一月','二月','三月','四月','五月','六月',
                '七月','八月','九月','十月','十一月','十二月'],
                monthNamesShort: ['一','二','三','四','五','六',
                '七','八','九','十','十一','十二'],
                dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
                dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],
                dayNamesMin: ['日','一','二','三','四','五','六'],
                weekHeader: '周',
                dateFormat: 'yy-mm-dd',
                firstDay: 1,
                isRTL: false,
                showMonthAfterYear: true,
                yearSuffix: '年'
            };
            $.datepicker.setDefaults($.datepicker.regional['zh-CN']);
                
     $('#simpliest-usage').multiDatesPicker({
                numberOfMonths: [3,4],
                addDates: dates, //初始化时选择的日期
                // beforeShowDay: $.datepicker.noWeekends,
                // changeMonth: true,
                // changeYear: true,
                defaultDate: y+'-01-01',
                // shortYearCutoff: 1,
                // monthNames:['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
                // dayNamesMin: ['日','一', '二', '三', '四', '五', '六'] 
                // regional:["zh-CN"]
    });
     
     
   $("#btnGetDates").on('click', function (e) {
       var setdates = $('#simpliest-usage').multiDatesPicker('getDates');
       var obj = document.getElementById("attendplan-check_date");  
        obj.value = setdates.toLocaleString();
       // alert(setdates.toLocaleString());

   });
JS;
$this->registerJs($js);
?>